/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package All.BO;

import All.DTO.AccountDTO;
import All.Mapper.AccountMapper;
import java.util.ArrayList;

/**
 *
 * @author NGUYEN DANG
 */
public class AccountBO {

    public AccountBO()
    {
        
    }
    public boolean login(String username, String password) throws Exception {
		AccountMapper mapper = null;
		boolean found = false;
		try {
			mapper = new AccountMapper();
			found = mapper.login(username, password);
		}
		catch (Exception e) {
			throw e;
		}
		
		return found;
	}
    public AccountDTO getUserInformation(String username) throws Exception {
		AccountMapper mapper = null;
		try {
			mapper = new AccountMapper();
			return mapper.getUserInformation(username);
		}
		catch (Exception e) {
			throw e;
		}
	}
    public ArrayList<AccountDTO> listUser() throws Exception {
		AccountMapper mapper = null;
		try {
			mapper = new AccountMapper();
			return mapper.listUser();
		}
		catch (Exception e) {
			throw e;
		}
    }

    public boolean ADupdate(AccountDTO accountDTO) throws Exception {
        boolean found;
        AccountMapper mapper = null;
        try
        {
            mapper = new AccountMapper();
            found = mapper.ADupdate(accountDTO); 
        }
        catch(Exception e)
        {
            throw e;
        }
        return found;
    }

    public boolean insert(AccountDTO accountDTO) throws Exception {
        boolean found = false ;
        AccountMapper mapper;
        try{
            mapper = new AccountMapper();
            found = mapper.insert(accountDTO);
        }
        catch(Exception e)
        {
            throw e;
        }
        return found;
    }

    public boolean ADDeleteUser(String username) throws Exception {
        boolean found = false;
        AccountMapper mapper;
        try{
            mapper = new AccountMapper();
            found = mapper.ADDeleteUser(username);
        }
        catch(Exception e)
        {
            throw e;
        }
        return found;
    }
   
}
